AO3-7135 Record canonized/decanonized dates on tags - #5954
Conversation
ed85026 to
b2c6cf2
Compare
sarken
left a comment
There was a problem hiding this comment.
Looking pretty good! Could you add a test in features/tags_and_wrangling/tag_search.feature to check the results of sorting?
| And I should not see "Last decanonized on" | ||
| When I check "Canonical" | ||
| And I press "Save changes" | ||
| And I edit the tag "Amelie" |
There was a problem hiding this comment.
Once you save changes, you should be redirected to the tag edit page, so this step would ideally be unnecessary... Did you try it without? (I can understand if you did and it failed due to the test running too quickly, but I wanted to ask just the same.)
| <% if @tag.canonized_at || @tag.decanonized_at %> | ||
| <p class="notes"> | ||
| <% if @tag.canonized_at %> | ||
| <%= t(".last_canonized", date: @tag.canonized_at.utc.strftime("%Y-%m-%d %H:%M:%S")) %> |
There was a problem hiding this comment.
Do we need strftime here? I get the desired format just by using utc (although, to be fair, I tried it on @tag.updated_at since that was what I had handy)
There was a problem hiding this comment.
With .utc is close but not quite, it gives something like 2026-07-29 04:32:07.699239 UTC, which includes microseconds. The strftime trims the microseconds and the UTC, giving just 2026-07-29 04:32:07. Then using the i18n we include the UTC again "Last canonized on 2026-07-29 04:32:07 UTC"
Pull Request Checklist
AO3-1234 Fix thing)Issue
https://otwarchive.atlassian.net/browse/AO3-7135
Purpose
Adds two new datetime columns (
canonized_atanddecanonized_at) to thetagstable to record when a tag was most recently canonized or decanonized.before_savecallback setscanonized_atwhen a tag becomes canonical, anddecanonized_atwhen it becomes non-canonical.Testing Instructions
superadmin,policy_and_abuse, ortag_wranglingrole.Credit
Pablo Monfort (he/him)